<?php
//是否已设置头像
function isSetAvatar($uid){
    return is_file( SITE_PATH.'/data/uploads/avatar/'.$uid.'/small.jpg');
}

	
/**
 * 检查Email是否可用
 * 
 * @param int $uid 用户ID, 不为0时排除给定用户
 * @return boolean
 */
function isEmailAvailable($email, $uid = 0) {
	if ($uid == 0) {
		return ! M('user')->where('`email`="'.$email.'"')->find();
	}else {
		return ! M('user')->where('`email`="'.$email.'" AND `id` <> '.$uid)->find();
	}
}


//获取用户姓名
function getUserName($uid,$lang='zh'){
	static $_MapName = array();
	if(!isset($_MapName[$uid])){
		if(is_numeric($uid)){
			$map['uid']   = $uid;
		}else{
			$map['uname'] = $uid;
		}
		$userinfo = M('User')->where($map)->field('uname')->find();
		$_MapName[$uid] = $userinfo['uname'];
	}
	return htmlspecialchars($_MapName[$uid]);
}


/*
 *获取用户组。（暂时未用到）
 */
function getUserGroupIcon($uid){
		return '';
	//return Model('UserGroup')->getUserGroupIcon($uid);
}


?>